
export default {
    /**
     * 展开树
     * @param list
     * @returns {*[]|*}
     */
    treeExpansion : function (list) {
        if (!list || list.length == 0) {
            return list;
        }
        let copy = [];//拷贝一份  不影响原来的list  因为是响应式的
        for (let i = 0; i < list.length; i++) {
            copy[i] = list[i];
        }
        let result = [];
        while (copy.length > 0) {
            let item = copy.pop();
            if (!item) {
                continue;
            }
            result.push(item);
            let children = item.children;
            if (children && children.length > 0) {
                for (let i = 0; i < children.length; i++) {
                    copy.push(children[i])
                }
            }
        }
        return result;
    }
}
